'''
Colony Use Case Tests

1) Create Colony (check values)
2) Edit Colony (Check Values)
3) Delete Colony
'''

from interactive import *

#1)

New()
css("#ColonyDetail #Name").send_keys("test")
Select(css("#ColonyDetail #GenderDefault")).select_by_value("F")
css("#ColonyDetail #Comment").send_keys("test comment with a bunch o' text")
Done()

Edit()
linkpart("test").click()
twait()

assert(Select(id("GenderDefault")).first_selected_option.text == "Female")
assert(id("Comment").get_attribute("value") == "test comment with a bunch o' text")

#2)

#Will it just append?
Edit()
css("#ColonyDetail #Name").clear()
css("#ColonyDetail #Name").send_keys("Inproved Test")
Select(css("#ColonyDetail #GenderDefault")).select_by_value("M")
css("#ColonyDetail #Comment").clear()
css("#ColonyDetail #Comment").send_keys("I think therefore I am")
Done()
twait()

Edit()
linkpart("Inproved Test").click()
twait()

assert(Select(css("#ColonyDetail #GenderDefault")).first_selected_option.text == "Male")
assert(css("#ColonyDetail #Comment").get_attribute("value") == "I think therefore I am")

#3)

Back()
twait()

Edit()
driver.execute_script("return $('#ColonyView li').has (':contains(\"Inproved Test\")').find('a').has('.ui-icon-delete')[0]").click() 
alert = driver.switch_to_alert()
assert(alert.text == "Are you sure you wish to delete Inproved Test?")
alert.accept()



driver.quit()
